<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<?php
// specify the LDAP server to connect to
$conn = ldap_connect("187.141.55.243",389) or die("Could not connect to server");  
// bind to the LDAP server specified above 
$r = ldap_bind($conn,'arios86','enconfianza123') or die("Could not bind to server");     
// start searching
// specify both the start location and the search criteria
// in this case, start at the top and return all entries 
$result = ldap_search($conn,"ou=enConfianza,dc=enconfianza,dc=mx", "(cn=*)") or die ("Error in search
query");  
// get entry data as array
$info = ldap_get_entries($conn, $result);
// iterate over array and print data for each entry
for ($i=0; $i<$info["count"]; $i++) 
{
//echo "dn is: ". $info[$i]["dn"] ."<br>";
//echo  $info[$i]["cn"][0]."<br>";
//echo  $info[$i]["sn"][0]."<br>";
//echo "first email address is: ". $info[$i]["mail"][0] ."<p>"; 
echo $info[$i]["mail"][0].",<br>";
}


echo "<br>Numero de correos: " . ldap_count_entries($conn, $result) .
"<p>";
ldap_close($conn);
?>
</body>
</html>